package cn.cckggroup.springboot.study.controller;

import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;

/**
 * @author zz
 * @date 2023/3/1
 */
@RestController
public class FallbackController {

    @GetMapping("/fallback")
    public String fallback(ServerWebExchange exchange) {
        Throwable executeException = exchange.getAttribute(ServerWebExchangeUtils.HYSTRIX_EXECUTION_EXCEPTION_ATTR);
        assert executeException != null;
        return "服务降级..." + executeException.getMessage();
    }
}
